<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('查看问题')" />
    <link href="/css/star/application.css" th:href="@{/css/star/application.css}" rel="stylesheet"/>

</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <div>
        <ul>
            <li class="wttw_head">问题提问</li>
        </ul>
    </div>
    <form class="form-horizontal m" id="form-dfQuestion-edit" th:object="${dfQuestion}">
        <input id="id" name="id" th:field="*{id}"  type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">用户名称：</label>
            <div class="col-sm-8">
                <input id="userName" name="userName" th:field="*{userName}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label">用户id：</label>
            <div class="col-sm-8">
                <input id="userId" name="userId" th:field="*{userId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">用户单位：</label>
            <div class="col-sm-8">
                <input id="userDept" name="userDept" th:field="*{userDept}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label">用户单位id：</label>
            <div class="col-sm-8">
                <input id="userDeptId" name="userDeptId" th:field="*{userDeptId}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label">联系方式：</label>
            <div class="col-sm-8">
                <input id="userPhone" name="userPhone" th:field="*{userPhone}" class="form-control" type="text" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input id="questionAnswer" name="questionAnswer" class="form-control" type="text" th:field="*{questionAnswer}">
            </div>
        </div>
        <div class="form-group" style="display: none">
            <label class="col-sm-3 control-label">问题处理结果：</label>
            <div class="col-sm-8">
                <input id="questionState" name="questionState" th:field="*{questionState}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题类型：</label>
            <div class="col-sm-8" style="padding-top: 3px;">
                <select name="questionType" class="form-control">
                    <option value="2"  th:field="*{questionType}">处理</option>
                    <option value="3"  th:field="*{questionType}">解释</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题版本号：</label>
            <div class="col-sm-8">
                <select name="questionVersion" class="form-control" th:with="type=${@dict.getType('df_question_version')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:field="*{questionVersion}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题标题：</label>
            <div class="col-sm-8">
                <input id="questionTitle" name="questionTitle" th:field="*{questionTitle}" class="form-control" type="text" readonly>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题描述：</label>
            <div class="col-sm-8">
                <textarea id="questionContent" name="questionContent" th:field="*{questionContent}" class="form-control" type="text" readonly></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">附件：</label>
            <div class="col-sm-8">
                <ul th:each="file,fileStat : ${dfQuestion.files}" style="padding-left: 0px;">
                    <img class="question_imgFile" th:src="${file.fileId}" th:if="${file.fileType=='png'||file.fileType=='jpg'}">
                    <a th:href="${file.fileId}"><img th:src="@{/img/tb_word.png}" th:if="${file.fileType=='docx'||file.fileType=='doc'}"></a>
                    <a th:href="${file.fileId}"><img th:src="@{/img/tb_excel.png}" th:if="${file.fileType=='xls'||file.fileType=='xlsx'}"></a>
                    <a th:href="${file.fileId}"><img th:src="@{/img/tb_zip.png}" th:if="${file.fileType=='zip'||file.fileType=='rar'}"></a>
                    <a th:href="${file.fileId}"><img th:src="@{/img/tb_ppt.png}" th:if="${file.fileType=='ppt'||file.fileType=='pptx'}"></a>
                </ul>
            </div>
        </div>
        <div id="outerdiv" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
            <div id="innerdiv" style="position:absolute;">
                <img id="bigimg" style="border:5px solid #fff;" src="" />
            </div>
        </div>

        <div class="form-group" th:if="*{questionState}=='4'">
            <label class="col-sm-3 control-label">退回原因：</label>
            <div class="col-sm-8">
                <textarea style="positon: absolute; float: left; width: 475px;" id="returnReason" name="remark" maxlength="500" class="form-control" rows="3" th:field="*{remark}" readonly/></textarea>
            </div>
        </div>

        <div class="form-group" th:each="list:${dfQuestionChild}">
            <ul>
                <li class="wttw_head">问题解决</li>
            </ul>
            <div style="margin-top: 20px;" th:if="${list.questionType== '2'}">
                <label  class="col-sm-3 control-label">解决方案：</label>
                <div class="col-sm-8">
                    <textarea  th:text="${list.questionInfo}" class="form-control" type="text" readonly></textarea>
                </div>
                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <ul th:each="file,fileStat : ${list.files}">
                        <img class="question_imgFile" th:src="${file.fileId}" th:if="${file.fileType=='png'||file.fileType=='jpg'}" data-id="${file.id}">
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_word.png}" th:if="${file.fileType=='docx'||file.fileType=='doc'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_excel.png}" th:if="${file.fileType=='xls'||file.fileType=='xlsx'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_zip.png}" th:if="${file.fileType=='zip'||file.fileType=='rar'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_ppt.png}" th:if="${file.fileType=='ppt'||file.fileType=='pptx'}"></a>
                    </ul>
                </div>
                <div id="outerdiv2" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
                    <div id="innerdiv2" style="position:absolute;">
                        <img id="bigimg2" style="border:5px solid #fff;" src="" />
                    </div>
                </div>

            </div>
            <div style="margin-top: 20px;" th:if="${list.questionType== '1'}">
                <label class="col-sm-3 control-label">追加问题描述：</label>
                <div class="col-sm-8">
                    <textarea  name="questionInfo"  th:text="${list.questionInfo}" class="form-control" type="text" readonly></textarea>
                </div>

                <label class="col-sm-3 control-label">附件：</label>
                <div class="col-sm-8">
                    <ul th:each="file,fileStat : ${dfQuestion.files}">
                        <img class="question_imgFile" th:src="${file.fileId}" th:if="${file.fileType=='png'||file.fileType=='jpg'}" data-id="${file.id}">
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_word.png}" th:if="${file.fileType=='docx'||file.fileType=='doc'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_excel.png}" th:if="${file.fileType=='xls'||file.fileType=='xlsx'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_zip.png}" th:if="${file.fileType=='zip'||file.fileType=='rar'}"></a>
                        <a th:href="${file.fileId}"><img th:src="@{/img/tb_ppt.png}" th:if="${file.fileType=='ppt'||file.fileType=='pptx'}"></a>
                    </ul>
                </div>
                <div id="outerdiv3" style="position:fixed;top:0;left:0;background:rgba(0,0,0,0.7);z-index:2;width:100%;height:100%;display:none;">
                    <div id="innerdiv3" style="position:absolute;">
                        <img id="bigimg3" style="border:5px solid #fff;" src="" />
                    </div>
                </div>
            </div>
        </div>
    </form>

</div>


<div th:include="include::footer"></div>
<script type="text/javascript">

    $(function () {
        $(".question_imgFile").width($(".col-sm-8").width());

    })
    //点击图片 在弹出层显示大图
    $(function(){
        $(".question_imgFile").click(function(){
            var _this = $(this);//将当前的pimg元素作为_this传入函数
            imgShow("#outerdiv", "#innerdiv", "#bigimg", _this);
        });
    });
    function imgShow(outerdiv, innerdiv, bigimg, _this){
        var src = _this.attr("src");//获取当前点击的pimg元素中的src属性
        $(bigimg).attr("src", src);//设置#bigimg元素的src属性

        /*获取当前点击图片的真实大小，并显示弹出层及大图*/
        $("<img/>").attr("src", src).load(function(){
            var windowW = $(window).width();//获取当前窗口宽度
            var windowH = $(window).height();//获取当前窗口高度
            var realWidth = this.width;//获取图片真实宽度
            var realHeight = this.height;//获取图片真实高度
            var imgWidth, imgHeight;
            var scale = 0.8;//缩放尺寸，当图片真实宽度和高度大于窗口宽度和高度时进行缩放

            if(realHeight>windowH*scale) {//判断图片高度
                imgHeight = windowH*scale;//如大于窗口高度，图片高度进行缩放
                imgWidth = imgHeight/realHeight*realWidth;//等比例缩放宽度
                if(imgWidth>windowW*scale) {//如宽度扔大于窗口宽度
                    imgWidth = windowW*scale;//再对宽度进行缩放
                }
            } else if(realWidth>windowW*scale) {//如图片高度合适，判断图片宽度
                imgWidth = windowW*scale;//如大于窗口宽度，图片宽度进行缩放
                imgHeight = imgWidth/realWidth*realHeight;//等比例缩放高度
            } else {//如果图片真实高度和宽度都符合要求，高宽不变
                imgWidth = realWidth;
                imgHeight = realHeight;
            }
            $(bigimg).css("width",imgWidth);//以最终的宽度对图片缩放

            var w = (windowW-imgWidth)/2;//计算图片与窗口左边距
            var h = (windowH-imgHeight)/2;//计算图片与窗口上边距
            $(innerdiv).css({"top":h, "left":w});//设置#innerdiv的top和left属性
            $(outerdiv).fadeIn("fast");//淡入显示#outerdiv及.pimg
        });

        $(outerdiv).click(function(){//再次点击淡出消失弹出层
            $(this).fadeOut("fast");
        });
    }
</script>
</body>
</html>
